package com.danskin.wechat.service.impl;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.danskin.wechat.api.client.WeiXinOpenApiClient;
import com.danskin.wechat.dao.SceneQrcodeDao;
import com.danskin.wechat.dao.SceneQrcodeStatisDao;
import com.danskin.wechat.dao.WxAuthTicketDao;
import com.danskin.wechat.dao.WxCardConfigDao;
import com.danskin.wechat.dao.WxFansCardDao;
import com.danskin.wechat.dao.WxFansInfoDao;
import com.danskin.wechat.dao.WxFansMsgDao;
import com.danskin.wechat.dao.WxFansMsgReplyDao;
import com.danskin.wechat.dao.WxMediaPlatformDao;
import com.danskin.wechat.dao.WxMenuClickDao;
import com.danskin.wechat.dao.WxMenuInfoDao;
import com.danskin.wechat.dao.WxMessageDao;
import com.danskin.wechat.dao.WxMessageNewsDao;
import com.danskin.wechat.dao.WxMpFuncInfoDao;
import com.danskin.wechat.dao.WxMsgReplyDetailDao;
import com.danskin.wechat.entity.SceneQrcode;
import com.danskin.wechat.entity.SceneQrcodeStatis;
import com.danskin.wechat.entity.SceneQrcodeStatisView;
import com.danskin.wechat.entity.WxAuthTicket;
import com.danskin.wechat.entity.WxCardConfig;
import com.danskin.wechat.entity.WxFansCard;
import com.danskin.wechat.entity.WxFansInfo;
import com.danskin.wechat.entity.WxFansInfoView;
import com.danskin.wechat.entity.WxFansMsg;
import com.danskin.wechat.entity.WxFansMsgReply;
import com.danskin.wechat.entity.WxFansMsgView;
import com.danskin.wechat.entity.WxMediaPlatform;
import com.danskin.wechat.entity.WxMenuClick;
import com.danskin.wechat.entity.WxMenuInfo;
import com.danskin.wechat.entity.WxMessage;
import com.danskin.wechat.entity.WxMessageNews;
import com.danskin.wechat.entity.WxMpFuncInfo;
import com.danskin.wechat.entity.WxMsgReplyDetail;
import com.danskin.wechat.service.WechatOpService;
import com.danskin.wechat.util.DateUtils;
import com.danskin.wechat.util.Page;
import com.danskin.wechat.util.StringUtil;
import com.danskin.wechat.util.WeXinQrCodeUtil;
import com.danskin.wechat.vo.WxMenuInfoVo;

@Service
public class WechatOpServiceImpl extends BaseServiceImpl implements WechatOpService {

	@Autowired
	private WxAuthTicketDao ticketDao;

	@Autowired
	private WxMediaPlatformDao mediaPlatformDao;

	@Autowired
	private WxMpFuncInfoDao functInfoDao;

	@Autowired
	private WxMsgReplyDetailDao replyDetailDao;

	@Autowired
	private WxFansCardDao fansCardDao;

	@Autowired
	private WxMenuInfoDao menuDao;

	@Autowired
	private WxMenuClickDao menuClickDao;

	@Autowired
	private WxFansMsgDao fansMsgDao;

	@Autowired
	private WxFansMsgReplyDao fansMsgReplyDao;

	@Autowired
	private WxFansInfoDao fansInfoDao;

	@Autowired
	private WxCardConfigDao cardConfigDao;

	@Autowired
	private SceneQrcodeDao sceneQrcodeDao;

	@Autowired
	private SceneQrcodeStatisDao sceneQrcodeStatisDao;

	@Autowired
	private WxMessageDao wxMessageDao;

	@Autowired
	private WxMessageNewsDao wxMessageNewsDao;

	/**
	 * 保存or修改
	 */
	@Override
	public void saveOrUpdateTicket(WxAuthTicket ticket) {

		WxAuthTicket existsTicket = ticketDao.queryByAppId(ticket.getAppId());
		if (existsTicket == null) {
			ticketDao.insert(ticket);
		} else {
			ticketDao.updateByAppId(ticket);
		}

	}

	@Override
	public WxAuthTicket getAuthTicket(String appId) {
		return ticketDao.queryByAppId(appId);
	}

	@Override
	public void saveWxMediaPlatform(WxMediaPlatform entity) {
		WxMediaPlatform getEntity = mediaPlatformDao.queryByAppId(entity.getAppId());

		if (getEntity == null) {
			entity.setCreatedTime(new Date());
			mediaPlatformDao.insertSelective(entity);
		} else {
			entity.setId(getEntity.getId());
			entity.setLastModifiedTime(new Date());
			mediaPlatformDao.updateByPrimaryKeySelective(entity);
		}
	}

	@Override

	public void saveMediaPlatformAndFunc(WxMediaPlatform entity, List<WxMpFuncInfo> funcs) {
		WxMediaPlatform getEntity = mediaPlatformDao.queryByAppId(entity.getAppId());
		if (getEntity == null) {
			entity.setCreatedTime(new Date());
			mediaPlatformDao.insertSelective(entity);
		} else {
			entity.setId(getEntity.getId());
			entity.setLastModifiedTime(new Date());
			mediaPlatformDao.updateByPrimaryKeySelective(entity);
			// 删除原有权限集
			functInfoDao.deleteByMpId(entity.getId());
		}
		// 保存权限集
		if (funcs != null && funcs.size() > 0) {
			for (WxMpFuncInfo f : funcs) {
				f.setMpId(entity.getId());
			}
			functInfoDao.insertBatch(funcs);
		}
	}

	@Override
	public WxMediaPlatform queryMediaPlatform(int mpId) {
		return mediaPlatformDao.selectByPrimaryKey(mpId);
	}

	@Override
	public WxMediaPlatform queryMediaPlatformByAppId(String appId) {

		return mediaPlatformDao.queryByAppId(appId);
	}

	@Override
	public List<WxMsgReplyDetail> findReplyDetailList(Page page) {
		return replyDetailDao.listPageReplyDetailList(page);
	}

	@Override
	public List<WxMsgReplyDetail> findReplyDetail(int mpId, String replyType) {

		return replyDetailDao.selectByReplyType(mpId, replyType);
	}

	@Override
	public WxMsgReplyDetail findReplyDetailKeyword(int mpId, String keyword) {

		return replyDetailDao.selectByKeyword(mpId, keyword);
	}

	@Override
	public void saveMsgReplyDetail(WxMsgReplyDetail entity) {

		if (entity.getId() == 0) {
			replyDetailDao.insert(entity);
		} else {
			entity.setLastModifiedTime(new Date(System.currentTimeMillis()));
			replyDetailDao.updateByPrimaryKeySelective(entity);
		}

	}

	@Override
	public void saveFansCard(WxFansCard entity) {

		WxFansCard fansCard = fansCardDao.queryByOpenIdAndCardId(entity.getOpenId(), entity.getWxCardId(),
				entity.getUserCardCode());
		if (fansCard == null) {
			fansCardDao.insertSelective(entity);
		} else {
			entity.setId(fansCard.getId());
			entity.setLastModifiedTime(new Date(System.currentTimeMillis()));
			fansCardDao.updateByPrimaryKeySelective(entity);
		}
	}

	@Override
	public WxFansCard queryFansCard(String openId, String cardId, String userCardCode) {

		WxFansCard fansCard = fansCardDao.queryByOpenIdAndCardId(openId, cardId, userCardCode);

		return fansCard;
	}

	@Override
	public void updateFansCard(WxFansCard entity) {

		entity.setLastModifiedTime(new Date(System.currentTimeMillis()));
		fansCardDao.updateByPrimaryKeySelective(entity);
	}

	@Override
	public WxMsgReplyDetail queryMsgReplyDetail(int id, int mpId) {

		WxMsgReplyDetail condition = new WxMsgReplyDetail();
		condition.setId(id);
		condition.setMpId(mpId);
		return replyDetailDao.selectWxMsgReplyDetailById(condition);
	}

	@Override
	public int deleteMsgReplyDetail(int id, int mpId) {

		// WxMsgReplyDetail condition = new WxMsgReplyDetail();
		// condition.setId(id);
		// condition.setMpId(mpId);

		return replyDetailDao.deleteByPrimaryKey(id, mpId);
	}

	@Override
	public List<WxMenuInfo> queryAllMenu(int mpId) {

		return menuDao.selectByMpId(mpId);
	}

	@Override
	public WxMenuInfo queryMenuInfo(int menuId, int mpId) {

		return menuDao.selectByPrimaryKey(menuId, mpId);
	}

	@Override
	public int saveMenuInfo(WxMenuInfo entity) {

		if (entity.getType().equals("2")) {// 跳转链接
			entity.setMenuKey(entity.getUrl());
		} else {// 点击
			entity.setMenuKey(StringUtil.getShortUUID());
			entity.setUrl(null);
		}
		entity.setOrderNum(1);
		if (entity.getId() == null || entity.getId() == 0) {
			// entity.setMenuKey(StringUtil.getShortUUID());
			menuDao.insert(entity);
			return entity.getId();
		} else {
			entity.setLastModifiedTime(new Date());
			return menuDao.updateByPrimaryKeySelective(entity);
		}
	}

	@Override
	public int saveMenuClick(WxMenuInfoVo menuInfo, String openId) {
		WxMenuClick menuClick = new WxMenuClick();
		menuClick.setMpId(menuInfo.getMpId());
		menuClick.setOpenId(openId);
		menuClick.setMenuId(menuInfo.getId());
		menuClick.setMenuName(menuInfo.getName());
		menuClick.setParentMenuId(menuInfo.getParentId());
		menuClick.setParentMenuName(menuInfo.getParentName());
		menuClick.setAction(Integer.valueOf(menuInfo.getType()));
		menuClick.setEventKey(menuInfo.getMenuKey());
		menuClick.setInDay(DateUtils.date2Integer());

		return this.menuClickDao.insertSelective(menuClick);
	}

	@Override
	public WxMenuInfoVo findMenuInfoByMenuKey(int mpId, String menuKey) {

		return menuDao.selectByMenuKey(menuKey, mpId);
	}

	@Override
	public int publishWechatMenu(String accessToken, int mpId) {

		List<WxMenuInfo> list = menuDao.selectByMpId(mpId);
		if (list != null && list.size() > 0) {
			JSONArray buttons = new JSONArray();
			List<WxMenuInfo> menus = this.getChildren(list, 0);
			for (WxMenuInfo menu : menus) {
				JSONObject first = new JSONObject();
				List<WxMenuInfo> children = this.getChildren(list, menu.getId());
				if (children != null && children.size() > 0) {
					first.put("name", menu.getName());
					JSONArray sub_buttons = new JSONArray();
					for (WxMenuInfo child : children) {
						// JSONObject second = new JSONObject();
						sub_buttons.add(generateMenu(child));
					}
					first.put("sub_button", sub_buttons);
					buttons.add(first);
				} else {
					buttons.add(generateMenu(menu));
				}

			}

			JSONObject result = WeiXinOpenApiClient.createInstance().createMenu(accessToken, buttons);
			if (result != null) {
				return result.getIntValue("errcode") == 0 ? 1 : 0;
			}
		}
		return 0;
	}

	private JSONObject generateMenu(WxMenuInfo menu) {
		JSONObject json = new JSONObject();
		json.put("name", menu.getName());
		if (menu.getType().equals("1")) {
			json.put("type", "click");
			json.put("key", menu.getMenuKey());
		} else if (menu.getType().equals("2")) {
			json.put("type", "view");
			json.put("url", menu.getUrl());
		}
		return json;
	}

	private List<WxMenuInfo> getChildren(List<WxMenuInfo> list, int parentId) {
		List<WxMenuInfo> children = new ArrayList<WxMenuInfo>();
		for (WxMenuInfo menu : list) {
			if (menu.getParentId().equals(parentId)) {
				children.add(menu);
			}
		}

		return children;
	}

	@Override
	public int deleteMenuInfo(int id, int mpId) {
		WxMenuInfo entity = new WxMenuInfo();
		entity.setParentId(id);
		entity.setMpId(mpId);
		long childrenNum = menuDao.countByEntity(entity);
		if (childrenNum == 0) {
			return menuDao.deleteByPrimaryKey(id, mpId);
		}

		return 0;
	}

	@Override
	public List<WxFansMsgView> findFansMsgList(Page page) {

		return fansMsgDao.listPageList(page);
	}

	@Override
	public int saveFansMsg(WxFansMsg entity) {

		return fansMsgDao.insert(entity);
	}

	@Override
	public WxFansMsgView findFansMsgView(int msgId, int mpId) {

		return fansMsgDao.selectViewByPrimarykey(msgId, mpId);
	}

	@Override
	public List<WxFansMsgReply> findFansMsgReplyByMsgId(int msgId, int mpId) {

		WxFansMsgReply entity = new WxFansMsgReply();
		entity.setFansMsgId(msgId);
		entity.setMpId(mpId);

		return fansMsgReplyDao.selectWxFansMsgReplyList(entity);
	}

	@Override

	public int kfReplyMsg(String accessToken, WxFansMsgReply entity) {
		int result = 0;
		WxFansMsgView msg = fansMsgDao.selectViewByPrimarykey(entity.getFansMsgId(), entity.getMpId());
		if (msg != null) {
			JSONObject response = WeiXinOpenApiClient.createInstance().sendKfTextMessage(accessToken, msg.getOpenId(),
					entity.getContent());
			if (response != null && response.getString("errcode").equals("0")) {
				// WxFansMsg msg = new WxFansMsg();
				// msg.setId(entity.getFansMsgId());
				// msg.setMpId(entity.getMpId());
				msg.setReplyStatus(1);
				msg.setLastModifiedTime(new Date());
				result = fansMsgDao.updateByPrimaryKey(msg); // 重置为已回复状态
				if (result > 0) {
					fansMsgReplyDao.insert(entity); // 保存客服回复记录

					// 调用微信接口，回复客服消息
				}
			} else {
				result = -1; // 超过48个小时不能回复
			}

		}

		return result;
	}

	@Override
	public List<WxFansInfoView> findFansInfoList(Page page) {

		return fansInfoDao.listPageList(page);
	}

	@Override
	public void syncFansFromWechat(String accessToken, int mpId) {

		List<WxFansInfo> allOpenId = fansInfoDao.selectAllOpenIdByMpId(mpId);
		syncFansLoop(accessToken, mpId, "", allOpenId);
	}

	private void syncFansLoop(String accessToken, int mpId, String nextOpenId, List<WxFansInfo> allOpenId) {
		JSONObject json = WeiXinOpenApiClient.createInstance().getFansList(accessToken, nextOpenId);
		if (json != null && json.containsKey("count")) {
			int count = json.getIntValue("count");
			if (count > 0) {

				JSONArray array = json.getJSONObject("data").getJSONArray("openid");
				for (int i = 0; i < array.size(); i++) {
					String openId = array.get(i).toString();

					JSONObject userInfo = WeiXinOpenApiClient.createInstance().getFansInfo(accessToken, openId);
					if (userInfo != null && userInfo.containsKey("openid")) {
						WxFansInfo fansInfo = this.checkByOpenId(openId, allOpenId);
						saveFansInfo(userInfo, fansInfo, mpId, null);
					}
				}

				// 获取下一组数据
				String nextOneOpenId = json.getString("next_openid");
				syncFansLoop(accessToken, mpId, nextOneOpenId, allOpenId);
			}
		}
	}

	private WxFansInfo checkByOpenId(String openId, List<WxFansInfo> allOpenId) {
		for (WxFansInfo fans : allOpenId) {
			if (fans.getOpenId().equals(openId)) {
				return fans;
			}
		}
		return null;
	}

	@Override
	public WxFansInfo saveFansInfo(JSONObject userInfo, WxFansInfo fansInfo, int mpId, Integer custExId) {

		if (fansInfo == null) {
			fansInfo = new WxFansInfo();
		}
		fansInfo.setMpId(mpId);
		fansInfo.setUnionId(this.getJSONValue("unionid", userInfo));//
		fansInfo.setOpenId(this.getJSONValue("openid", userInfo));
		String nickName = StringUtil.filterEmoji(this.getJSONValue("nickname", userInfo));
		fansInfo.setNickName(nickName);
		fansInfo.setHeadImgUrl(this.getJSONValue("headimgurl", userInfo));// (userInfo.getString("headimgurl"));
		if (this.getJSONValue("sex", userInfo) != null) {
			fansInfo.setGender(userInfo.getInteger("sex"));
		}
		fansInfo.setCity(this.getJSONValue("city", userInfo));// (userInfo.getString("city"));
		fansInfo.setProvince(this.getJSONValue("province", userInfo));// (userInfo.getString("province"));
		fansInfo.setCountry(this.getJSONValue("country", userInfo));// (userInfo.getString("country"));
		fansInfo.setLanguage(this.getJSONValue("language", userInfo));// (userInfo.getString("language"));
		if (this.getJSONValue("subscribe", userInfo) != null) {
			fansInfo.setSubscribe(userInfo.getInteger("subscribe"));
		}
		if (this.getJSONValue("subscribe_time", userInfo) != null) {
			fansInfo.setSubscribeTime(new Date(userInfo.getLongValue("subscribe_time") * 1000));
		} else {
			if (fansInfo.getSubscribe() == null) {
				fansInfo.setSubscribeTime(new Date());
			}
		}
		if (this.getJSONValue("groupid", userInfo) != null) {
			fansInfo.setGroupId(userInfo.getInteger("groupid"));
		}
		fansInfo.setRemark(this.getJSONValue("remark", userInfo));// (userInfo.getString("remark"));
		if (this.getJSONValue("tagid_list", userInfo) != null) {
			fansInfo.setTagidList(userInfo.getJSONArray("tagid_list").toJSONString());
		}
		fansInfo.setCustExId(custExId);
		if (fansInfo.getId() != null && fansInfo.getId().intValue() > 0) {
			fansInfo.setLastModifiedTime(new Date());
			fansInfoDao.updateByPrimaryKeySelective(fansInfo);
		} else {
			if (custExId != null && custExId != 0) {
				WxFansInfo oldFansInfo = fansInfoDao.selectByCustExId(mpId, custExId);
				if (oldFansInfo != null) {
					oldFansInfo.setCustExId(0);
					oldFansInfo.setLastModifiedTime(new Date());
					fansInfoDao.updateByPrimaryKeySelective(oldFansInfo);
				}
			}

			fansInfoDao.insertSelective(fansInfo);
		}

		return fansInfo;
	}

	@Override
	public WxFansInfo saveFansInfo(String accessToken, int mpId, String openId, Integer custExId) {
		JSONObject userInfo = WeiXinOpenApiClient.createInstance().getFansInfo(accessToken, openId);
		if (userInfo != null && userInfo.containsKey("openid")) {
			WxFansInfo fansInfo = fansInfoDao.selectByOpenId(mpId, openId);
			return saveFansInfo(userInfo, fansInfo, mpId, custExId);
		}
		return null;
	}

	@Override
	public WxCardConfig findCardConfig(String cardType, String appId) {

		return cardConfigDao.selectByCardType(cardType, appId);
	}

	@Override
	public WxCardConfig findCardConfig(int mpId, String cardId) {

		return cardConfigDao.selectByCardId(mpId, cardId);
	}

	@Override
	public List<SceneQrcode> findSceneQrcodeList(Page page) {

		return sceneQrcodeDao.listPageList(page);
	}

	@Override
	public SceneQrcode saveSceneQrcode(String access_token, SceneQrcode entity, String realPath) {
		if (entity.getId() == null || entity.getId() == 0) {
			int expireSeconds = 0;
			if (entity.getLimitType() == 0) {
				Calendar now = Calendar.getInstance();
				Calendar end = Calendar.getInstance();
				end.setTime(entity.getExpiredTime());
				entity.setStartTime(now.getTime());
				expireSeconds = DateUtils.dateDiff('s', end, now);
			}

			String ticket = "";
			JSONObject json = WeiXinOpenApiClient.createInstance().createQrcode(access_token, entity.getLimitType(),
					expireSeconds, entity.getSceneStr());
			if (json != null && json.containsKey("ticket")) {
				ticket = json.getString("ticket");
			}

			String url = "";
			try {
				url = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + URLEncoder.encode(ticket, "GBK");
			} catch (UnsupportedEncodingException e) {

				e.printStackTrace();
			}
			// 生成带logo的二维码并返回二维码地址
			String ftpQrCodeUrl = WeXinQrCodeUtil.getAddLogoQrCode(url, realPath);
			entity.setTicket(ticket);
			entity.setQrcodeUrl(ftpQrCodeUrl);

			sceneQrcodeDao.insertSelective(entity);
		} else {
			entity.setLastModifiedTime(new Date(System.currentTimeMillis()));
			sceneQrcodeDao.updateByPrimaryKeySelective(entity);
		}

		return entity;
	}

	@Override
	public SceneQrcode saveSceneQrcodeWithReply(String access_token, SceneQrcode entity, String realPath,
			WxMessage message, List<WxMessageNews> news) {
		if (entity.getId() == null || entity.getId() == 0) {
			int expireSeconds = 0;
			if (entity.getLimitType() == 0) {
				Calendar now = Calendar.getInstance();
				Calendar end = Calendar.getInstance();
				end.setTime(entity.getExpiredTime());
				entity.setStartTime(now.getTime());
				expireSeconds = DateUtils.dateDiff('s', end, now);
			}

			String ticket = "";
			JSONObject json = WeiXinOpenApiClient.createInstance().createQrcode(access_token, entity.getLimitType(),
					expireSeconds, entity.getSceneStr());
			if (json != null && json.containsKey("ticket")) {
				ticket = json.getString("ticket");
			}

			String url = "";
			try {
				url = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + URLEncoder.encode(ticket, "GBK");
			} catch (UnsupportedEncodingException e) {

				e.printStackTrace();
			}
			// 生成带logo的二维码并返回二维码地址
			String ftpQrCodeUrl = WeXinQrCodeUtil.getAddLogoQrCode(url, realPath);
			entity.setTicket(ticket);
			entity.setQrcodeUrl(ftpQrCodeUrl);

			int messageId = 0;
			if (message != null) {
				wxMessageDao.insertSelective(message);
				messageId = message.getId();
				if (message.getMsgType().equals(4) && news != null) {
					for (WxMessageNews o : news) {
						o.setMessageId(messageId);
					}

					wxMessageNewsDao.insertBatch(news);
				}
			}
			entity.setMessageId(messageId);
			sceneQrcodeDao.insertSelective(entity);
		} else {
			Integer messageId = entity.getMessageId();
			if (message != null) {
				if (messageId != null && messageId > 0) {
					message.setId(messageId);
					message.setLastModifiedTime(new Date());
					wxMessageDao.updateByPrimaryKeySelective(message);

					wxMessageNewsDao.deleteByMessageId(messageId);
				} else {
					wxMessageDao.insertSelective(message);
					messageId = message.getId();
				}
				if (message.getMsgType().equals(4) && news != null) {
					for (WxMessageNews o : news) {
						o.setMessageId(messageId);
					}

					wxMessageNewsDao.insertBatch(news);
				}
			}
			entity.setSceneStr(null);// 不允许修改。
			entity.setMessageId(messageId);
			entity.setLastModifiedTime(new Date());

			sceneQrcodeDao.updateByPrimaryKeySelective(entity);
		}
		return entity;
	}

	@Override
	public SceneQrcode querySceneQrcode(int id, int mpId) {

		return sceneQrcodeDao.selectById(id, mpId);
	}

	@Override
	public int deleteSceneQrcode(int id, int mpId) {

		return sceneQrcodeDao.deleteByPrimaryKey(id, mpId);
	}

	@Override

	public SceneQrcode saveQrcodeStatis(int mpId, String sceneStr, String openId, Integer eventType) {

		SceneQrcode qrcode = sceneQrcodeDao.selectBySceneStr(mpId, sceneStr);
		if (qrcode != null) {
			SceneQrcodeStatis qrcodeStatis = new SceneQrcodeStatis();
			qrcodeStatis.setMpId(mpId);
			qrcodeStatis.setSceneQrcodeId(qrcode.getId());
			qrcodeStatis.setOpenId(openId);
			qrcodeStatis.setEventType(eventType);
			qrcodeStatis.setScanTime(new Date());
			sceneQrcodeStatisDao.insertSelective(qrcodeStatis);

			// 累计扫描次数
			sceneQrcodeDao.updateScanTimesById(qrcode);
		}
		return qrcode;
	}

	@Override
	public List<SceneQrcodeStatisView> findSceneQrcodeStatisList(Page page) {

		return sceneQrcodeStatisDao.listPageList(page);
	}
}
